import http from "@/utils/request"

// 分页查询库存信息详情
export function getProcessByPage (pageNum, pageSize, processingId) {
  return http({
    url: `/processing/processingStorage/list/${pageNum}/${pageSize}?processingId=${processingId}`,
    method: 'get',
  });
}

// 根据id查询详情
export function getProcessById (id) {
  return http({
    url: `/processing/processingStorage/get/${id}`,
    method: 'get',
  });
}

// 添加
export function addEvent (addForm) {
  return http({
    url: `/processing/processingStorage/save`,
    method: 'post',
    data: {
      count: addForm.count,
      preprice: addForm.preprice,
      price: addForm.price,
      referPrice: addForm.referPrice,
      remark: addForm.remark,
      specification: addForm.specification,
      total: addForm.total,
      typeId: addForm.typeId,
      typeName: addForm.typeName
    }
  })
}

// 修改
export function editEvent (editForm, id) {
  return http({
    url: `/processing/processingStorage/update/${id}`,
    method: 'put',
    data: {
      count: editForm.count,
      preprice: editForm.preprice,
      price: editForm.price,
      referPrice: editForm.referPrice,
      remark: editForm.remark,
      specification: editForm.specification,
      total: editForm.total,
      typeId: editForm.typeId,
      typeName: editForm.typeName
    }
  })
}

// 批量删除
export function delInfo () {
  return http({
    url: `/processing/processingStorage/deletion/batch`,
    method: 'delete'
  });
}

// 根据id删除
export function delInfoById (id) {
  return http({
    url: `/processing/processingStorage/delete/${id}`,
    method: 'delete'
  });
}

export function searchInfoByvariety () {
  return http({
    url: `/processing/processingStorage/deletion/batch`,
    method: 'delete'
  });
}


export function dateShorter (target, key) {
  target.forEach(item =>
    item[key] = item[key].slice(0, 10)
  )
}